//以后直接赋值,去vue.router官网

//1.包装 yarn add vue-router@3.5.3
//2.在main.js中引入vuerouter构造函数
import VueRouter from 'vue-router'

//引入vue
import Vue from 'vue';

//引入组件
import Layout from '../views/Layout.vue'
import ArticleDetail from '../views/ArticleDetail.vue'
import Collect from '../views/Collect.vue'
import Like from '../views/Like.vue'
import User from '../views/User.vue'
import Article from '../views/Article.vue'





//3.安装插件-帮我们注册全局组件 router-view router-link
Vue.use(VueRouter)

//4.创建路由对象
//核心步骤
//a.配置路由规则
//b.指定路由出口(组件渲染到哪里)
const routes=[
  {
    //配置一级路由
    //记得在App.vue中配置路由的出口
    path:'/',
    component:Layout,
    //配置子路由(二级路由)
    children:[
      { path:'article',component:Article},
      { path:'collect',component:Collect},
      { path:'like',component:Like},
      { path:'user',component:User}


    ]
  },
  {
    path:'/detail',
    component:ArticleDetail
  },
]

//b
const router=new VueRouter({
 routes,
  mode:'hash'
})
export default router